package demo.test.controller;


import com.entites.DataDeviceSet;
import com.entites.DeviceSet;
import demo.test.service.DataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
public class CollectionController {
    @Value("${server.port}")
    private String port;


    @Resource
    private DataService dataService;


    /**
     * 做一个简单的查询
     * */
    @GetMapping("/get/{id}")
    public DeviceSet  getData(@PathVariable("id") Integer id){

        DeviceSet device=dataService.getDeviceSet(id);
        return device;

    }



    @GetMapping("/getA")
    public List<DeviceSet> getDeviceSets(){

        List<DeviceSet> result = dataService.getDeviceSets();
        log.info(String.valueOf(result));

return result;
    }


    @PostMapping("/getO/{device}")
    public DeviceSet getDeviceSetss(@RequestBody DeviceSet device){

        System.out.println(device.toString());

        return device;
    }


    @GetMapping(value="/get/dataV-t_data_device",produces = "application/json; charset=utf-8")
    public List<DataDeviceSet> get_t_data_device(){
        List<DataDeviceSet> result =dataService.getDataDevice();

        log.info(String.valueOf(result));
        return result;
    }




}
